# Contributor: Bart Ribbers <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-frameworks
maintainer="team/kde <bribbers@disroot.org>"
pkgname=ktexttemplate
pkgver=6.7.0
pkgrel=0
pkgdesc="Library to allow application developers to separate the structure of documents from the data they contain"
arch="all !armhf" # armhf blocked by extra-cmake-modules
url="https://community.kde.org/Frameworks"
license="LGPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="
	doxygen
	extra-cmake-modules
	qt6-qtbase-dev
	samurai
	graphviz
	qt6-qttools-dev
	"
checkdepends="xvfb-run"
subpackages="$pkgname-dev $pkgname-doc"
_repo_url="https://invent.kde.org/frameworks/ktexttemplate.git"
source="https://download.kde.org/stable/frameworks/${pkgver%.*}/ktexttemplate-$pkgver.tar.xz"

build() {
	# Tests fail with -O2 on aarch64
	# https://lists.debian.org/debian-arm/2024/08/msg00038.html
	case "$CARCH" in
		aarch64)
			export CFLAGS="$CFLAGS -O1"
			export CXXFLAGS="$CXXFLAGS -O1"
			;;
	esac

	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_TESTING=ON \
		-DBUILD_QCH=ON
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}
sha512sums="
a4739ac35ee88fa2c41e383fa659c8af4bea60611c9508807e9b78ff535ad9db461561ec97f00143dabd795352cc665ed221f0a82afc6b8fb7caf76cdb941206  ktexttemplate-6.7.0.tar.xz
"
